package stateDiagram.figures;

import static org.jhotdraw.draw.AttributeKeys.FONT_BOLD;

import org.jhotdraw.draw.ListFigure;
import org.jhotdraw.draw.TextFigure;
import org.jhotdraw.draw.layouter.HorizontalLayouter;

import stateDiagram.EntityObjects.Event;
import stateDiagram.EntityObjects.StateEntity;

public class InternalTransitionFigure extends ListFigure {
	private StateEntity state;
	public InternalTransitionFigure(String eventName, String actionName, StateEntity state){
	 super();
	 this.state=state;
	 setLayouter( new HorizontalLayouter());
	 Event event = new Event(eventName);
	 state.addEvent(event);
	 EventTextFigure eventTextFigure = new EventTextFigure(event);
     eventTextFigure.setEditable(true);
     eventTextFigure.setText(eventName);
     eventTextFigure.setAttributeEnabled(FONT_BOLD, false);
     
     TextFigure slash = new TextFigure("/");
     
     ActionTextFigure actionTextFigure= new ActionTextFigure(actionName, event);
     actionTextFigure.setEditable(true);
     actionTextFigure.setText(actionName);
     actionTextFigure.setAttributeEnabled(FONT_BOLD, false);
     add(eventTextFigure);
     add(slash);
     add(actionTextFigure);
	}
public void setEvent(String eventName){
	((EventTextFigure)getChild(0)).setText(eventName);
}

public String getEvent(){
	return ((EventTextFigure)getChild(0)).getText();
}
}
